package org.shoukaiseki.common.utils;

import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 日志工具
 * org.shoukaiseki.common.utils.LoggingUtils
 * <br>
 *
 * @author shoukaiseki ブログ http://www.shoukaiseki.top/<br> E-メール jiang28555@Gmail.com<br>
 * @date 2020-11-21 16:28:35<br>
 */
public class LoggingUtils {

    public static final String LOGGING_PREFIX="--------------------------------";

    public static final Logger logger=LoggerFactory.getLogger(LoggingUtils.class);

    /**
     * springboot debug输出所有参数
     */
    public static void printRequestParameterMap(){
        if (logger.isDebugEnabled()) {
            HttpServletRequest request = ServletUtils.getHttpServletRequest();
            Map<String, String[]> parameterMap = request.getParameterMap();
            parameterMap.forEach((k,v)->{
                logger.debug(LOGGING_PREFIX+"k,"+k+",v="+ JSONObject.toJSONString(v));
            });
        }
    }


}
